package com.yl.pattern.behavioralmodel.command;

import java.util.Set;

/**
 * @Author 小羊
 * @Date 31/10/2024下午 4:32
 * @ClassName OrderCommand
 * @Description 具体的命令类
 */
public class OrderCommand implements Command{

    /**
     * 持有接收者对象
     */
    private SeniorChef receiver;
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order){
        this.receiver = receiver;
        this.order = order;
    }

    @Override
    public void execute()  {
        System.out.println(order.getDiningTable() + "桌的订单：");
        Set<String> keys = order.getFoodDir().keySet();
        for (String key : keys) {
            receiver.makeFood(order.getFoodDir().get(key),key);
        }

        try {
            //停顿一下 模拟做饭的过程
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        System.out.println(order.getDiningTable() + "桌的饭弄好了");
    }
}
